from rest_framework import serializers
from . import models

class GoodsUnserializer(serializers.Serializer):
    name=serializers.CharField(max_length=32)
    price=serializers.DecimalField(max_digits=9,decimal_places=2)
    img=serializers.ImageField()
    count=serializers.IntegerField()

    def create(self, validated_data):
        return models.Goods.objects.create(**validated_data)


class GoodsSerializer(serializers.ModelSerializer):
    class Meta:
        model=models.Goods
        fields="__all__"
